#! /bin/bash

function check_installed(){
    q=$1
    where=`which $q`
    installed=$?
    if [[ $installed -ne 0 ]];then
        echo -e "\033[31m $q is not installed, now try to install git \033[0m"
        until [[ $installed -eq 0 ]]
        do
            sudo apt-get install $q
            where=`which $q`
            installed=$?
        done
    fi
    echo -e "\033[32m $q is installed at $where \033[0m"

    return $installed
}

#function check_version(){
#}

# check git installed
#SYSTEM_VERSION=`uname -a`
#TODO add system version check

check_installed git

check_installed vim

# setup Vundle
#TODO check Vundle installed
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
if [[ $? -eq 0 ]];then
cp ./vimrc ~/.vimrc
else
    echo -e "\033[31m setup Vundle failed \033[0m"
    exit 1
fi

#setup YouCompletme
#check_version vim "7.4.13"
